<template>
  <div id='LeftSideList'>
    <div class='box'>
      <h3>云音乐特色榜</h3>
      <ul>
        <li v-for='item in cloudMusicFeatureList' :key='item.id'>
          <router-link :to='`/toplist?id=${item.id}`' :class="{active:currentListId == item.id}">
            <img :src='`${item.coverImgUrl}?param=40y40`'>
            <div>
              <span>{{ item.name }}</span><br>
              <span class='gray-font'>{{ item.updateFrequency }}</span>
            </div>
          </router-link>
        </li>
      </ul>
    </div>
    <div class='box'>
      <h3>全球媒体榜</h3>
      <ul>
        <li v-for='item in globalMediaList' :key='item.id'>
          <router-link :to='`/toplist?id=${item.id}`'>
            <img :src='`${item.coverImgUrl}?param=40y40`'>
            <div>
              <span>{{ item.name }}</span><br>
              <span class='gray-font'>{{ item.updateFrequency }}</span>
            </div>
          </router-link>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LeftSideList',
  data() {
    return {
      cloudMusicFeatureList: [],
      globalMediaList: [],
    }
  },
  mounted() {
    this.$API.topListDetail().then(res => {
      this.cloudMusicFeatureList = res.data.list.slice(0, 4)
      this.globalMediaList = res.data.list.slice(4)
    })
  },
  computed:{
    currentListId(){ // 用于判断给不给当前 li的 class加 active
      return this.$route.query.id * 1 || 19723756
    }
  }
}
</script>

<style scoped lang='less'>
#LeftSideList {
  width: 250px;
  border: 1px solid #e6e6e6;
  background-color: #f9f9f9;

  ul {

    li a {
      display: flex;
      height: 60px;
      width: 100%;
      flex-flow: row nowrap;
      font-size: 12px;
      font-family: Arial, Helvetica, sans-serif;
      padding: 10px 0 0 10px;

      img {
        width: 40px;
        height: 40px;
        vertical-align: baseline;
        margin-right: 15px;
      }
    }

    li a:hover {
      background-color: #f4f2f2;
    }

    .active {
      background-color: #e6e6e6;
    }
  }


  .box {
    margin-top: 20px;

    h3 {
      margin-left: 12px;
    }
  }
}

.gray-font {
  color: #999999;
  margin-top: 10px;
  display: inline-block;
}
</style>